package com.changhong.wlyspectrum.NewDesign;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.changhong.wlyspectrum.R;
import com.changhong.wlyspectrum.utils.MyCollectionData;
import com.changhong.wlyspectrum.utils.MyEditText;

/**
 * Created by Mr_tao
 * on 2017/4/11.
 */
public class CollectionActivity extends Activity{
    private final static String TAG = "CollectionActivity";
    private ImageView mBackImv;
    private Button mbutton = null;
    private MyEditText edittext1 = null;
    private MyEditText edittext2 = null;

    private EditText medit_name = null;
    private EditText medit_descri = null;
    private TextView mtext_name = null;
    private TextView mtext_descri = null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collection_layout);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar_collection);

        mBackImv = (ImageView)findViewById(R.id.collection2home);
        mBackImv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        edittext1 = (MyEditText)findViewById(R.id.mtext_name);
        edittext2 = (MyEditText)findViewById(R.id.mtext_descri);

        mtext_name = (TextView)edittext1.findViewById(R.id.my_name);
        medit_name = (EditText)edittext1.findViewById(R.id.my_descri);
        mtext_name.setText(getResources().getString(R.string.collection_name));
        medit_name.setHint(getResources().getString(R.string.collection_namehint));

        mtext_descri = (TextView)edittext2.findViewById(R.id.my_name);
        medit_descri = (EditText)edittext2.findViewById(R.id.my_descri);
        mtext_descri.setText(getResources().getString(R.string.collection_descri));
        medit_descri.setHint(getResources().getString(R.string.collection_descrihint));


        mbutton = (Button)findViewById(R.id.next_step);
        mbutton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                String name = medit_name.getText().toString();
                String descri = medit_descri.getText().toString();

                if(!TextUtils.isEmpty(name))
                {
                    MyCollectionData mData= new MyCollectionData();
                    mData.setName(name);
                    mData.setDescri(descri);

                    Intent mintent = new Intent(getApplicationContext(),AttributeActivity.class);
                    mintent.putExtra("FLAG","1");
                    mintent.putExtra("MY_DATA", mData);
                    startActivity(mintent);
                }else{
                    Toast.makeText(getApplicationContext(),getResources().getString(R.string.isnull), Toast.LENGTH_LONG).show();
                }
            }
        });
    }

}
